<template>

<tr>
    <td v-show="!is_edit">{{student.number}}</td>
    <td v-show="!is_edit">{{student.name}}</td>
    <td v-show="!is_edit">{{student.age}}</td>
    <td v-show="!is_edit">{{student.chinese}}</td>
    <td v-show="!is_edit">{{student.math}}</td>
    <td v-show="!is_edit">{{student.english}}</td>
    <td v-show="!is_edit">
        <el-button type="primary" @click="modify">修改</el-button>
    </td>
    <td v-show="!is_edit">
        <el-button type="danger" @click="deleteStudent">删除</el-button>
    </td>

    <td v-show="is_edit"><input class="w-50" type="text" v-model="student.number"/></td>
    <td v-show="is_edit"><input class="w-50" type="text" v-model="student.name"/></td>
    <td v-show="is_edit"><input class="w-50" type="text" v-model.number="student.age"/></td>
    <td v-show="is_edit"><input class="w-50" type="text" v-model.number="student.chinese"/></td>
    <td v-show="is_edit"><input class="w-50" type="text" v-model.number="student.math"/></td>
    <td v-show="is_edit"><input class="w-50" type="text" v-model.number="student.english"/></td>
    <td v-show="is_edit">
        <el-button type="primary" @click="save">保存</el-button>
    </td>

    <td v-show="is_edit">
        <el-button type="danger" @click="deleteStudent">确认删除</el-button>
    </td>
</tr>

</template>

<script>
import axios from 'axios';
export default {
    props:["student"],
    data(){
        return{
            is_edit:false
        }
    },
    methods:{
    modify(){
        this.is_edit=true;
    },
    //更新
    save(){
        axios({
            url: "http://43.140.196.117:8088/update",
            method: "POST",
            data:this.student
        })
        this.is_edit=false;
    },
    //删
    deleteStudent(){
        axios({
            url: "http://43.140.196.117:8088/delete",
            method: "POST",
            data:this.student
        })
    }
  }
}
</script>

<style>

</style>    